import { defHttp } from '@/utils/http/axios';
enum Api {
  analysisGetDataAPI = '/mv/data/dataSpeedlog',
  analysisGetdataLog = '/mv/data/dataLog',
  analysisGetNodeStatusAPI = '/mv/node/getNodeStatus',
  getNodeLogs = '/mv/node/nodeList',
  getEchartAPI = '/mv/data/getDataLog',
  getNodeLogsOfflineAPI = '/mv/node/nodeLogs',
  getNodeDetailAPI = '/mv/node/nodeDetail',
  getlistSumAPI = '/mv/data/listSum',
  getSuccessNuAPI = '/mv/data/orientCompleteSum',
  getaudioSumAPI = '/mv/data/audioSum',
  restartNodeAPI='/mv/node/restartNode',
  allRestartNodeAPI="/mv/node/allRestartNode",
  dataVectorizationAPI='/mv/data/dataVectorization'
}

//采集速率
export function analysisGetDataAPI() {
  return defHttp
    .get(
      {
        url: Api.analysisGetDataAPI,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    })
    .catch((err) => {
      console.log(err, '采集速率');
    });
}

//重启节点
export function restartNodeAPI(data) {
  return defHttp
    .get(
      {
        url: Api.restartNodeAPI+"?nodeIds="+ data,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    })
    .catch((err) => {
      console.log(err, '采集速率');
    });
}

//重启虚拟机
export function allRestartNodeAPI(data) {
  return defHttp
    .post(
      {
        url: Api.allRestartNodeAPI,
        data
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    })
    .catch((err) => {
      console.log(err, '采集速率');
    });
}

//节点状态
export function analysisGetNodeStatusAPI() {
  return defHttp
    .get(
      {
        url: Api.analysisGetNodeStatusAPI,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    })
    .catch((err) => {
      console.log(err, '节点状态');
    });
}

//今日数据
export function analysisGetdataLog() {
  return defHttp
    .get(
      {
        url: Api.analysisGetdataLog,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    })
    .catch((err) => {
      console.log(err, '今日数据');
    });
}

//节点记录
export function getNodeLogs(data) {
  return defHttp
    .get(
      {
        url: Api.getNodeLogs + '?target=' + data,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    })
    .catch((err) => {
      console.log(err, '节点记录');
    });
}
//获取echart数据
export function getcollectioncount() {
  return defHttp
    .get(
      {
        url: '/sys/analysis/collection/count',
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    })
    .catch((err) => {
      console.log(err, '节点记录');
    });
}
export function getEchartAPI() {
  return defHttp
    .get(
      {
        url: '/sys/analysis/collection/count',
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    })
    .catch((err) => {
      console.log(err, '节点记录');
    });
}
export function getNodeLogsOfflineAPI() {
  return defHttp
    .get(
      {
        url: Api.getNodeLogsOfflineAPI,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      // const { records, total } = res.data;
      return {
        items: res.data, // 将数据列表赋值给 items
        // total, // 直接使用 total
        total: res.data.length,
      };
    })
    .catch((err) => {
      console.log(err, '节点记录');
    });
}
//获取线程任务
export function getNodeDetailAPI(data) {
  return defHttp
    .get(
      {
        url: Api.getNodeDetailAPI + '?nodeId=' + data,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    })
    .catch((err) => {
      console.log(err, '节点记录');
    });
}
//转化量

export function getdataVectorizationAPI() {
  return defHttp
    .post(
      {
        url: Api.dataVectorizationAPI,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    })
    .catch((err) => {
      console.log(err, '任务列表量');
    });
}
//定向采集完成数
export function getSuccessNuAPI() {
  return defHttp
    .post(
      {
        url: Api.getSuccessNuAPI,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    })
    .catch((err) => {
      console.log(err, '任务完成数');
    });
}

//视频总量
export function getaudioSumAPI() {
  return defHttp
    .post(
      {
        url: Api.getaudioSumAPI,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    })
    .catch((err) => {
      console.log(err, '视频总量');
    });
}
